CHARTS

Poverty rates among lone-parents

the dumbell chart

Photo by Annie Spratt on Unsplash

Photo by Annie Spratt on Unsplash

As a single mum you’ll discover inner strengths and capabilities you never knew you had…
— Emma-Louise Smith


Ingest

Progress of the World’s Women Report, 2019-2020

df = read.csv("archetypes/worlds-women-report/figure-4-8_db.csv", header = TRUE, stringsAsFactors = FALSE) # read text file
df

View, chart

Poverty rates among lone-parents before and after transfers

# sort values and refactor
df <- df %>% arrange(desc(y1_axis)) %>% mutate(x_axis=factor(x_axis, levels=x_axis))

# create dumbbell plot
v1<-ggplot(df) +  
  geom_segment( aes(x = x_axis, xend = x_axis, y = y1_axis, yend = y2_axis), lineend = "butt", linejoin = "round", size=3.5, color="#d9d9d9" ) +
  geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
  geom_text( aes(x = x_axis, y = y2_axis, label=y2_axis), size=3, color="black", vjust = 2.5, fontface = "bold" ) +
  geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" ) +
  geom_text( aes(x = x_axis, y = y1_axis, label = y1_axis), size=3, color="black", vjust = -1.5, fontface = "bold" ) +
  scale_y_continuous(limits = c(0,60), breaks = c(0, 20, 40, 60), labels = c(0, 20, 40, 60)) +
  theme_minimal() + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
  theme( # remove the vertical grid lines
           panel.grid.major.x = element_blank(),
           # explicitly set the horizontal lines (or they will disappear too)
           panel.grid.major.y = element_line( size=.1, color="#cccccc" ),
           panel.grid.minor.y = element_blank()
    ) +
  labs(title = "POVERTY RATES AMONG LONE-PARENTS BEFORE AND AFTER TRANSFERS - Figure 4.8",
       subtitle = "SELECTED COUNTRIES, LATEST AVAILABLE YEAR", caption = "Source: UN Women",
       x = "",
       y = "Percentage")

girafe(ggobj = v1, width_svg = 1280/72, height_svg = 720/72,
       options = list(opts_sizing(rescale = TRUE, width = 1.0)))

Step by step

Plot the min and max points

# create dumbbell plot
v2 <- ggplot(df) +  
  geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
  geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" )

girafe(ggobj = v2, width_svg = 1280/72, height_svg = 720/72,
       options = list(opts_sizing(rescale = TRUE, width = 1.0)))

Connect the points with a vertical line (geom_segment)

# create dumbbell plot
v3 <- ggplot(df) +  
  geom_segment( aes(x = x_axis, xend = x_axis, y = y1_axis, yend = y2_axis), lineend = "butt", linejoin = "round", size=3.5, color="#d9d9d9" ) +
  geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
  geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" )

girafe(ggobj = v3, width_svg = 1280/72, height_svg = 720/72,
       options = list(opts_sizing(rescale = TRUE, width = 1.0)))

Add data labels

# create dumbbell plot
v4 <- ggplot(df) +  
  geom_segment( aes(x = x_axis, xend = x_axis, y = y1_axis, yend = y2_axis), lineend = "butt", linejoin = "round", size=3.5, color="#d9d9d9" ) +
  geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
  geom_text( aes(x = x_axis, y = y2_axis, label=y2_axis), size=3, color="black", vjust = 2.5, fontface = "bold" ) +
  geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" ) +
  geom_text( aes(x = x_axis, y = y1_axis, label = y1_axis), size=3, color="black", vjust = -1.5, fontface = "bold" )

girafe(ggobj = v4, width_svg = 1280/72, height_svg = 720/72,
       options = list(opts_sizing(rescale = TRUE, width = 1.0)))

Beautify by adding themes and amending axes settings

# sort values and refactor
df <- df %>% arrange(desc(y1_axis)) %>% mutate(x_axis=factor(x_axis, levels=x_axis))

# create dumbbell plot
v5 <- ggplot(df) +  
  geom_segment( aes(x = x_axis, xend = x_axis, y = y1_axis, yend = y2_axis), lineend = "butt", linejoin = "round", size=3.5, color="#d9d9d9" ) +
  geom_point( aes(x = x_axis, y = y2_axis), size=3, color="#5c96d6" ) +
  geom_text( aes(x = x_axis, y = y2_axis, label=y2_axis), size=3, color="black", vjust = 2.5, fontface = "bold" ) +
  geom_point( aes(x = x_axis, y = y1_axis), size=3, color="#692c7d" ) +
  geom_text( aes(x = x_axis, y = y1_axis, label = y1_axis), size=3, color="black", vjust = -1.5, fontface = "bold" ) +
  scale_y_continuous(limits = c(0,60), breaks = c(0, 20, 40, 60), labels = c(0, 20, 40, 60)) +
  theme_minimal() + 
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
  theme( # remove the vertical grid lines
           panel.grid.major.x = element_blank(),
           # explicitly set the horizontal lines (or they will disappear too)
           panel.grid.major.y = element_line( size=.1, color="#cccccc" ),
           panel.grid.minor.y = element_blank()
    ) +
  labs(title = "POVERTY RATES AMONG LONE-PARENTS BEFORE AND AFTER TRANSFERS - Figure 4.8",
       subtitle = "SELECTED COUNTRIES, LATEST AVAILABLE YEAR", caption = "Source: UN Women",
       x = "",
       y = "Percentage")

girafe(ggobj = v5, width_svg = 1280/72, height_svg = 720/72,
       options = list(opts_sizing(rescale = TRUE, width = 1.0)))

References

citations for narrative and data sources

  • Narrative and Data Source: UN Women, Progress of The World’s Women 2019-2020 Report, GO
@misc{unwomen_2019_progress,
  author = {UN Women},
  title = {Progress of the world’s women | Digital library},
  url = {https://www.unwomen.org/en/digital-library/progress-of-the-worlds-women},
  urldate = {2021-06-11},
  year = {2019},
  organization = {UN Women}
}